﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Labthink.PCSoft.UniversalHost4
{
    public partial class CaliSave
    {
        public string CaliName { get; set; }
        public string Remark { get; set; }
        public CaliSave()
        {
            InitializeComponent();
        }


        private void BtnSave_OnClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(TxtName.Value)) return;
            CaliName = TxtName.Value;
            Remark =TxtRemark.Value;
            DialogResult = true;
        }

        private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
        {
            Close();
        }

    
        private void CaliSave_OnLoaded(object sender, RoutedEventArgs e)
        {
           

            if (!string.IsNullOrEmpty(CaliName))
            {
                TxtName.Value = CaliName;
            }
            if (!string.IsNullOrEmpty(Remark))
            {
                TxtRemark.Value = Remark;
            }
        }

        private void TxtName_OnLostFocus(object sender, RoutedEventArgs e)
        {
            const string errChar = "\\/:*?\"<>|";
            for (int i = 0; i < errChar.Length; i++)
            {
                TxtName.Value = TxtName.Value.Replace(errChar[i] + "", "");
            }
        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if(e.LeftButton == MouseButtonState.Pressed) DragMove();
        }
    }
}
